import instance from "../request";
import axios from "axios";
import GLOBAL from '@/utils/global';

// 创建取消令牌
const CancelToken = axios.CancelToken;

export const document = {
    //获取全部文件列表信息
    getAllFileList: (data) => {
        return instance({
            url: '/data/getAllFileList',
            method: 'post',
            data
        })
    },
    //文件上传
    uploadFile: (data) => {
        return instance({
            url: '/data/uploadFile',
            method: 'post',
            data,
            timeout: 1000 * 60 * 30,
            cancelToken: new CancelToken(function executor(c) {
                GLOBAL.UPLOADCANCEL = c;
            })
        })
    },
    //文件下载
    //设置30分钟超时时间
    downloadFile: (data) => {
        return instance({
            url: '/data/downloadFile',
            method: 'post',
            data,
            timeout: 1000 * 60 * 30,
            responseType: "blob"
        })
    },
    //添加文件目录
    //设置30分钟超时时间
    addNewDirPath: (data) => {
        return instance({
            url: '/data/addNewDirPath',
            method: 'post',
            data,
            timeout: 1000 * 60 * 30,
        })
    }
}